FROM kubespheredev/builder-base:v3.3.1

# 设置环境变量
ENV MAVEN_VERSION=3.9.7
ENV PATH_NAME=jdk-17.0.13+11
ENV TZ=Asia/Shanghai

# 设置时区
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone


# 移除现有的 JDK 8
RUN if [ -d /usr/lib/jvm ]; then \
rm -rf /usr/lib/jvm/*; \
fi

# 下载并安装 OpenJDK 17
RUN mkdir -p /usr/lib/jvm && \
curl -f -L -o /tmp/$PATH_NAME.tar.gz https://mirrors.tuna.tsinghua.edu.cn/Adoptium/17/jdk/x64/linux/OpenJDK17U-jdk_x64_linux_hotspot_17.0.13_11.tar.gz && \
tar -xzf /tmp/$PATH_NAME.tar.gz -C /usr/lib/jvm && \
rm /tmp/$PATH_NAME.tar.gz

# 设置 Java 环境变量
ENV JAVA_HOME /usr/lib/jvm/$PATH_NAME
ENV PATH $JAVA_HOME/bin:$PATH

# 验证 Java 安装
RUN java -version

# 安装 Maven
RUN curl -f -L https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz | tar -C /opt -xzv
ENV MAVEN_HOME=/opt/apache-maven-$MAVEN_VERSION
ENV PATH $MAVEN_HOME/bin:$PATH

# 验证 Maven 安装
RUN mvn -v

# 设置默认命令
CMD [“mvn”]

